/*    */ package com.hs.activation.controller;
/*    */ 
/*    */ import com.hs.activation.common.annotation.PassToken;
/*    */ import com.hs.activation.common.result.BaseController;
/*    */ import com.hs.activation.common.result.Result;
/*    */ import com.hs.activation.entity.WxUserEntity;
/*    */ import com.hs.activation.entity.menuEntity;
/*    */ import com.hs.activation.service.IWxUserService;
/*    */ import com.hs.activation.service.ImenuService;
/*    */ import io.swagger.annotations.Api;
/*    */ import java.util.List;
/*    */ import javax.annotation.Resource;
/*    */ import org.springframework.web.bind.annotation.GetMapping;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.PostMapping;
/*    */ import org.springframework.web.bind.annotation.RequestBody;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.RestController;
/*    */ 
/*    */ @RestController
/*    */ @RequestMapping({"menu"})
/*    */ @Api(value = "用户菜单管理接口", tags = {"用户菜单管理接口"})
/*    */ public class MenuController extends BaseController {
/*    */   @Resource
/*    */   ImenuService service;
/*    */   @Resource
/*    */   IWxUserService userservice;
/*    */   
/*    */   @GetMapping({"/{id}"})
/*    */   @PassToken
/*    */   public Result queryList(@PathVariable Long id) {
/*    */     try {
/* 33 */       List<menuEntity> result = this.service.queryList(id);
/* 34 */       return new Result("操作成功", Integer.valueOf(200), result);
/* 35 */     } catch (Exception ee) {
/* 36 */       return new Result(ee.getMessage(), Integer.valueOf(400));
/*    */     } 
/*    */   }
/*    */   
/*    */   @PostMapping({""})
/*    */   @PassToken
/*    */   public Result save(@RequestBody menuEntity entity) {
/* 43 */     boolean result = false;
/* 44 */     if (entity.getId() == null) {
/* 45 */       result = this.service.save(entity);
/*    */     } else {
/* 47 */       result = this.service.update(entity);
/*    */     } 
/* 49 */     if (!result) {
/* 50 */       return new Result("操作失败", Integer.valueOf(400));
/*    */     }
/* 52 */     return new Result("操作成功", Integer.valueOf(200));
/*    */   }
/*    */   
/*    */   @GetMapping({"delete/{id}"})
/*    */   @PassToken
/*    */   public Result deleteById(@PathVariable Long id) {
/* 58 */     boolean result = this.service.removeById(id);
/* 59 */     if (result == true) {
/* 60 */       return new Result("删除成功", Integer.valueOf(200));
/*    */     }
/* 62 */     return fail("操作失败");
/*    */   }
/*    */   
/*    */   @GetMapping({"findbyopenid/{openid}"})
/*    */   @PassToken
/*    */   public Result findByOpenId(@PathVariable String openid) {
/* 68 */     WxUserEntity ss = this.userservice.findByOpenId(openid);
/* 69 */     if (ss != null) {
/* 70 */       List<menuEntity> menus = this.service.queryList(ss.getActivationid());
/* 71 */       if (menus != null && menus.size() > 0) {
/* 72 */         return new Result("查询成功", Integer.valueOf(200), menus);
/*    */       }
/* 74 */       return new Result("无数据", Integer.valueOf(200));
/*    */     } 
/* 76 */     return new Result("无数据", Integer.valueOf(200));
/*    */   }
/*    */ }


/* Location:              C:\Users\yzc\Desktop\新建文件夹 (3)\activation-0.0.16.jar!\BOOT-INF\classes\com\hs\activation\controller\MenuController.class
 * Java compiler version: 16 (60.0)
 * JD-Core Version:       1.1.3
 */